﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace InsideDL
{
    public static class Program
    {

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
           
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new frmInside());
            TempFolderExists();
            Application.Run(new frmMain());
        }

        public static void ShootDown()
        {
            Application.Exit();
        }

        /// <summary>
        /// 不存在就建立，固定建在Bin\Temp
        /// </summary>
        public static void TempFolderExists()
        {
            if (Directory.Exists(TmpPath()))
            {
                return;
            }
            Directory.CreateDirectory(TmpPath());
        }

        public static string TmpPath()
        {
            return string.Format(@"{0}\TEMP", Application.StartupPath);
        }

        /// <summary>
        /// 產生出文字檔案EX:TXT、CSV等
        /// </summary>
        /// <param name="p_filePath">完整的路徑+檔名</param>
        /// <param name="p_content">要填入的內容</param>
        public static void CreateFile(string p_filePath,string p_content)
        {
            using (FileStream filestr = new FileStream(p_filePath,FileMode.Create
                , FileAccess.Write))
            {
                using (StreamWriter writer = new StreamWriter(filestr, System.Text.Encoding.GetEncoding(950)))
                {
                    writer.Write(p_content);
                    writer.Close();
                }
                filestr.Close();
            }
        }

    }
}
